//
//  PicturePopView.m
//  QT
//
//  Created by 甘世清 on 2025/1/2.
//

#import "PicturePopView.h"

@implementation PicturePopView

- (void)yc_addSubViews{
    self.backgroundColor = UIColor.whiteColor;
    self.layer.borderColor = SQColorRedF5249.CGColor;
    self.layer.borderWidth =  1;
    self.layer.cornerRadius = 30;
    self.layer.masksToBounds = YES;
    self.clipsToBounds = YES;
    
    [self addSubview:self.pictureImageView];
    [self.pictureImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    [self addSubview:self.visualEffectView];
    [self.visualEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.pictureImageView);
    }];
    [self addSubview:self.headerView];
    [self addSubview:self.nameLabel];
    [self addSubview:self.timeLabel];
    [self addSubview:self.messageLabel];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(60);
            make.left.top.equalTo(self).offset(12);
    }];
//
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerView).offset(2);
        make.left.equalTo(self.headerView.mas_right).offset(10);
        make.height.mas_equalTo(20);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.headerView.mas_bottom).offset(-2);
        make.left.equalTo(self.headerView.mas_right).offset(10);
        make.height.mas_equalTo(20);
    }];
//
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(SCREEN_WIDETH-60-12-12-10-40);
        make.left.equalTo(self.timeLabel);
        make.top.equalTo(self.timeLabel.mas_bottom).offset(2);
    }];
  
}
- (void)setModel:(PictureModel *)model{
    _model = model;
    [self.headerView.headerImage sd_setImageWithURL:SQURLImage(model.portrait) placeholderImage:SQGetImage(@"2")];
    self.nameLabel.text = model.name;
    self.timeLabel.text = model.createTime;
    self.messageLabel.text = model.content;
    [self.pictureImageView sd_setImageWithURL:SQURLImage(model.imgs) placeholderImage:SQGetImage(@"1")];
    [self layoutIfNeeded];
}

-(void)SQ_HeaderViewButtonClick{
    PeopleDetailsViewController * vc = [[PeopleDetailsViewController alloc]init];
    [[Manager SQ_getCurrentViewController].navigationController pushViewController:vc animated:YES];
}

- (HeaderView *)headerView{
    if (!_headerView) {
        _headerView = [[HeaderView alloc]init];
        _headerView.layer.cornerRadius = 30;
        _headerView.layer.masksToBounds = YES;
        _headerView.headerImage.contentMode = UIViewContentModeScaleAspectFill;
        [_headerView.btn addTarget:self action:@selector(SQ_HeaderViewButtonClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _headerView;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = SQColor333333;
        _nameLabel.font = FONT_MEDIUM(16);
    }
    return _nameLabel;
}
- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.textColor = SQColor666666;
        _timeLabel.font = FONT_REGULAR(12);
    }
    return _timeLabel;
}
- (UIImageView *)pictureImageView{
    if (!_pictureImageView) {
        _pictureImageView = [[UIImageView alloc]init];
        _pictureImageView.contentMode = UIViewContentModeScaleAspectFill;
        _pictureImageView.clipsToBounds = YES;
    }
    return _pictureImageView;
}

- (UIVisualEffectView *)visualEffectView{
    if (!_visualEffectView) {
        UIBlurEffect * blureffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
        _visualEffectView = [[UIVisualEffectView alloc]initWithEffect:blureffect];
        _visualEffectView.layer.cornerRadius = 10;
        _visualEffectView.layer.masksToBounds = YES;
    }
    return _visualEffectView;
}

- (UILabel *)messageLabel{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc]init];
        _messageLabel.font = FONT_MEDIUM(12);
        _messageLabel.textColor = SQColor333333;
        _messageLabel.backgroundColor = UIColor.clearColor;
        _messageLabel.numberOfLines = 0;
    }
    return _messageLabel;
}
@end
